package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.dto.ProductSkuVo;
import com.spzx.product.api.dto.SkuPriceVo;
import com.spzx.product.api.factory.RemoteProductFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * we put all feign invoke in the api modules ,if you need feign, dependence this module
 */
@FeignClient(
        contextId = "remoteProductService" ,
        value = ServiceNameConstants.PRODUCT_SERVICE,
        path = "/productSku",
        fallbackFactory = RemoteProductFallbackFactory.class
)
public interface RemoteProductSkuService {//叫 ProductClient也行

    @GetMapping("/getProductSku/{skuId}")
    public R<ProductSkuVo> getProductSku(@PathVariable("skuId") Long skuId,
                                         @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping(value = "/getSkuPriceList")
    public R<List<SkuPriceVo>> getSkuPriceList(@RequestBody List<Long> skuIdList,
                                               @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/getSkuPrice/{skuId}")
    R<SkuPriceVo> getSkuPrice(@PathVariable("skuId") Long skuId,
                              @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
